var e = require;
var t = module;
var o = exports;
e("Interstitial").InterstitialType;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0}), e("App");
var s = e("AssetsMap"),
    c = e("BundleNames"),
    l = e("Util"),
    d = e("ConfigGameData"),
    u = e("GameData"),
    p = e("GameOverData"),
    h = e("nodePoolManager"),
    f = e("ProgressTaskData"),
    _ = e("GameModuleViewMediator"),
    y = e("bomb_prefab"),
    m = e("layer_blast"),
    g = e("PoisonMap"),
    v = e("view_killList"),
    w = e("CustomerFood"),
    b = e("CustomerSnakeLayer"),
    C = e("MapCommon"),
    k = e("SnakeBlockInfo"),
    N = e("StorehouseModel"),
    B = e("TestDebug"),
    P = e("layer_food"),
    I = e("layer_snake"),
    S =
        (window.wx,
        function (e) {
            (this.layer_UI = null),
                (this.view_joystick = null),
                (this.view_accelerate = null),
                (this.view_life = null),
                (this.view_gameTimer = null),
                (this.view_store_home = null),
                (this.view_rankingList = null),
                (this.view_score = null),
                (this.porp_magnet = null),
                (this.porp_double = null),
                (this.view_killToast = null),
                (this.view_killList = null),
                (this.label_countDown = null),
                (this.label_store_home_countDown = null),
                (this.skill_shield = null),
                (this.skill_missile = null),
                (this.layer_food = null),
                (this.layer_snake = null),
                (this.GameCamera = null),
                (this.touch_speet = null),
                (this.layer_snakesName = null),
                (this.rankContent = null),
                (this.layer_bomb = null),
                (this.layer_poison = null),
                (this.layer_blast = null),
                (this.progressTaskTip = null),
                (this.btn_recorder = null),
                (this.tip_arrow = null),
                (this.back = null),
                (this.tip1 = null),
                (this.tip2 = null),
                (this.layer_UI = e.node.getChildByName("layer_UI")),
                (this.tip1 = this.layer_UI.getChildByName("tip1")),
                (this.tip2 = this.layer_UI.getChildByName("tip2")),
                (this.view_joystick = this.layer_UI.getChildByName("view_joystick")),
                (this.view_accelerate = this.layer_UI.getChildByName("view_accelerate")),
                (this.view_life = this.layer_UI.getChildByName("view_life")),
                (this.view_gameTimer = this.layer_UI.getChildByName("view_gameTimer")),
                (this.view_store_home = this.layer_UI.getChildByName("view_store_home")),
                (this.view_rankingList = this.layer_UI.getChildByName("view_rankingList")),
                (this.view_score = this.layer_UI.getChildByName("view_score")),
                (this.porp_magnet = this.layer_UI.getChildByName("porp_magnet")),
                (this.porp_double = this.layer_UI.getChildByName("porp_double")),
                (this.view_killToast = this.layer_UI.getChildByName("view_killToast")),
                (this.view_killList = this.layer_UI.getChildByName("view_killList")),
                (this.label_countDown = this.view_gameTimer.getChildByName("label_countDown")),
                (this.label_store_home_countDown = this.view_store_home.getChildByName("label_countDown")),
                (this.skill_shield = this.view_accelerate.getChildByName("skill_shield")),
                (this.skill_missile = this.view_accelerate.getChildByName("skill_missile")),
                (this.layer_food = e.node.getChildByName("layer_food")),
                (this.layer_snake = e.node.getChildByName("layer_snake")),
                (this.GameCamera = e.node.getChildByName("GameCamera")),
                (this.touch_speet = this.view_accelerate.getChildByName("touch_speet")),
                (this.layer_snakesName = e.node.getChildByName("layer_snakesName")),
                (this.rankContent = this.layer_UI
                    .getChildByName("view_rankingList")
                    .getChildByName("ScrollView")
                    .getComponent(cc.ScrollView).content),
                (this.layer_bomb = e.node.getChildByName("layer_bomb")),
                (this.layer_poison = e.node.getChildByName("layer_poison")),
                (this.layer_blast = e.node.getChildByName("layer_blast")),
                (this.progressTaskTip = this.layer_UI.getChildByName("progressTaskTip")),
                (this.btn_recorder = this.layer_UI.getChildByName("btn_recorder")),
                (this.tip_arrow = e.node.getChildByName("tip_arrow")),
                (this.back = this.layer_UI.getChildByName("back"));
        }),
    A = cc._decorator,
    O = A.ccclass,
    R = A.property,
    T = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.gameModel = null),
                (t.viewModel = null),
                (t._timer = 0),
                (t._gameCameraPos = cc.v3(0, 0, 0)),
                (t._layer_food = null),
                (t._layer_snake = null),
                (t._poisonMap = null),
                (t._view_killList = null),
                (t._layer_blast = null),
                (t.snakeGridMap = null),
                (t.storeHoseModel = null),
                (t.testDebug = null),
                (t.isCreate = !1),
                (t.ifTipStore = !1),
                (t.preClickTimer = 0),
                (t.oldScore = 0),
                (t.Recordering = null),
                (t.Recorder_stop = null),
                (t.guideLeft = null),
                (t.guideRight = null),
                (t.isGuideLeft = !1),
                (t.isGuideRight = !1),
                (t._batch = 0),
                t
            );
        }
        var o;
        return (
            a(t, e),
            (o = t),
            (t.prototype.onResetView = function () {
                console.log("window.ad.Platform:", window.ad.Platform),
                    console.log("p.default.instance.GameModel:", u.default.instance.GameModel),
                    cc.SDK.hideBoxPortalAd(),
                    cc.SDK.hideBanner(),
                    e.prototype.onResetView.call(this),
                    (this.snakeGridMap = new C.default()),
                    this.snakeGridMap.init(8e3, 100, k.default),
                    this.checkStoreHoseModel(),
                    this.mapChange(),
                    (o.Insance = this),
                    (cc.find("Canvas/Main Camera").active = !1),
                    (this.viewModel = new S(this)),
                    (this.guideLeft = this.viewModel.tip1),
                    (this.guideRight = this.viewModel.tip2),
                    (this.isGuideLeft = "true" === l.default.getItem("isGuideLeft", "false")),
                    (this.isGuideRight = "true" === l.default.getItem("isGuideRight", "false")),
                    (this.guideLeft.active = !this.isGuideLeft),
                    (this.guideRight.active = !this.isGuideRight),
                    (u.default.instance.MapSize = this.node.getChildByName("mapSize").width),
                    (u.default.instance.againPlayTimes = 0),
                    (u.default.instance.gameState = u.GameState.ready),
                    (this.gameModel = u.default.instance.GameModel),
                    p.default.instance.ResetData(),
                    h.default.instance.init(this),
                    this.record();
            }),
            (t.prototype.onLoad = function () {
                this.isCache = !1;
            }),
            (t.prototype.record = function () {
                var e = ad.curr_platform === window.ad.Platform.TOU_TIAO;
                u.default.instance.GameModel !== u.GameModel.endless ||
                    u.default.instance.isStoreHose ||
                    u.default.instance.isIncome ||
                    (game.log("T=> 进入无尽模式"), e && window.tt.reportAnalytics("Moshi_WuJin_Start", {})),
                    u.default.instance.GameModel === u.GameModel.endless &&
                        u.default.instance.isStoreHose &&
                        (game.log("T=> 进入宝藏屋"), e && window.tt.reportAnalytics("YuZhouXingYun_Enter", {})),
                    u.default.instance.GameModel === u.GameModel.endless &&
                        !u.default.instance.isStoreHose &&
                        u.default.instance.isIncome &&
                        (game.log("T=> 出宝藏屋"), e && window.tt.reportAnalytics("YuZhouXingYun_End", {})),
                    u.default.instance.GameModel === u.GameModel.TimeLimit &&
                        (game.log("T=> 进入排位模式"), e && window.tt.reportAnalytics("Moshi_PaiWei_Start", {})),
                    u.default.instance.GameModel === u.GameModel.eatChicken &&
                        (game.log("T=> 进入乱斗模式"), e && window.tt.reportAnalytics("Moshi_LuanDou_Start", {}));
            }),
            (t.prototype.mapChange = function () {
                var e = this.node.getChildByName("mapSize"),
                    t = e.getChildByName("bg");
                if (u.default.instance.GameModel === u.GameModel.endless) {
                    var o = e.getChildByName("theme_4");
                    (t.active = !u.default.instance.isStoreHose),
                        (o.active = u.default.instance.isStoreHose),
                        u.default.instance.isStoreHose && this.addMapDeco(o, 4);
                } else if (u.default.instance.GameModel === u.GameModel.TimeLimit) {
                    t.active = !1;
                    var n = u.default.instance.themeIndex,
                        i = e.getChildByName("theme_" + n);
                    (i.active = !0), this.addMapDeco(i, n);
                }
            }),
            (t.prototype.addMapDeco = function (e, t) {
                if (1 !== t)
                    for (var o = this.node.getChildByName("mapSize").getChildByName("map_item_" + t), n = 0; n < 5; n++)
                        for (var i = 0; i < 5; i++) {
                            var a = l.default.randomFrom(1600 * n - 4e3, 1600 * (n + 1) - 4e3),
                                r = l.default.randomFrom(1600 * i - 4e3, 1600 * (i + 1) - 4e3),
                                s = cc.instantiate(o);
                            (s.active = !0),
                                (s.scale = 2),
                                (s.angle = l.default.randomFrom(0, 255)),
                                e.addChild(s),
                                (s.position = cc.v3(a, r));
                        }
            }),
            (t.prototype.addEvent = function () {
                this.viewModel &&
                    (e.prototype.addEvent.call(this),
                    this.viewModel.touch_speet.on(cc.Node.EventType.TOUCH_START, this.onTouchAccelerateStart, this),
                    this.viewModel.touch_speet.on(cc.Node.EventType.TOUCH_END, this.onTouchAccelerateEnd, this),
                    this.viewModel.touch_speet.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchAccelerateEnd, this),
                    u.default.instance.GameModel == u.GameModel.eatChicken &&
                        (this.viewModel.view_accelerate
                            .getChildByName("skill_missile")
                            .on(cc.Node.EventType.TOUCH_START, this.TOUCH_START_Missile, this),
                        this.viewModel.view_accelerate
                            .getChildByName("skill_missile")
                            .on(cc.Node.EventType.TOUCH_END, this.TOUCH_END_Missile, this),
                        this.viewModel.view_accelerate
                            .getChildByName("skill_missile")
                            .on(cc.Node.EventType.TOUCH_CANCEL, this.TOUCH_CANCEL_Missile, this),
                        this.viewModel.view_accelerate
                            .getChildByName("skill_shield")
                            .on(game.EngineEventType.NodeEvent.click, this.onClick_Shield, this)),
                    ad.curr_platform == window.ad.Platform.TOU_TIAO &&
                        this.viewModel.btn_recorder.on(
                            game.EngineEventType.NodeEvent.click,
                            this.onClick_btn_recorder,
                            this
                        ),
                    u.default.instance.GameModel == u.GameModel.TimeLimit &&
                        this.viewModel.back.on(game.EngineEventType.NodeEvent.click, this.clickBackGame, this));
            }),
            (t.prototype.removeEvent = function () {
                e.prototype.removeEvent.call(this),
                    this.viewModel.touch_speet.off(cc.Node.EventType.TOUCH_START, this.onTouchAccelerateStart, this),
                    this.viewModel.touch_speet.off(cc.Node.EventType.TOUCH_END, this.onTouchAccelerateEnd, this),
                    this.viewModel.touch_speet.off(cc.Node.EventType.TOUCH_CANCEL, this.onTouchAccelerateEnd, this),
                    this.gameModel == u.GameModel.TimeLimit && this.unschedule(this.gameCountDown),
                    u.default.instance.GameModel == u.GameModel.eatChicken &&
                        (this.viewModel.view_accelerate
                            .getChildByName("skill_missile")
                            .off(cc.Node.EventType.TOUCH_START, this.TOUCH_START_Missile, this),
                        this.viewModel.view_accelerate
                            .getChildByName("skill_missile")
                            .off(cc.Node.EventType.TOUCH_END, this.TOUCH_END_Missile, this),
                        this.viewModel.view_accelerate
                            .getChildByName("skill_missile")
                            .off(cc.Node.EventType.TOUCH_CANCEL, this.TOUCH_CANCEL_Missile, this),
                        this.viewModel.view_accelerate
                            .getChildByName("skill_shield")
                            .off(game.EngineEventType.NodeEvent.click, this.onClick_Shield, this)),
                    ad.curr_platform == window.ad.Platform.TOU_TIAO &&
                        this.viewModel.btn_recorder.off(
                            game.EngineEventType.NodeEvent.click,
                            this.onClick_btn_recorder,
                            this
                        ),
                    u.default.instance.GameModel == u.GameModel.TimeLimit &&
                        this.viewModel.back.off(game.EngineEventType.NodeEvent.click, this.clickBackGame, this);
            }),
            (t.prototype.registerMediator = function () {
                e.prototype.registerMediator.call(this), game.appFacade.registerMediator(new _.default(this));
            }),
            (t.prototype.removeMediator = function () {
                e.prototype.removeMediator.call(this), game.appFacade.removeMediator(_.default.NAME);
            }),
            (t.prototype.playAgain = function (e) {
                var t = this;
                void 0 === e && (e = 0),
                    0 == e
                        ? (this._layer_snake.playerControl._snake.playAgain(),
                          u.default.instance.tt_recorder_flags && o.Insance.onClick_btn_recorder())
                        : this.scheduleOnce(function () {
                              u.default.instance.gameState == u.GameState.play &&
                                  (u.default.instance.tt_recorder_flags && o.Insance.onClick_btn_recorder(),
                                  t._layer_snake.playerControl._snake.playAgain());
                          }, 3);
            }),
            (t.prototype.autoReplaceFPS = function () {
                var e = [];
                this.schedule(
                    function () {
                        if (cc.profiler && cc.profiler.getStats) {
                            var t = cc.profiler.getStats().fps._counter.value;
                            if (!t) return;
                            if ((e.push(t), 5 === e.length)) {
                                for (var o = 0, n = 0; n < e.length; n++) o += e[n];
                                var i = o / e.length;
                                game.log("平均帧率:" + i),
                                    30 === cc.game.getFrameRate() &&
                                        (i >= 110 && i <= 120
                                            ? cc.game.setFrameRate(30)
                                            : i <= 50
                                            ? cc.game.setFrameRate(30)
                                            : (game.log("不降帧"), cc.game.setFrameRate(60)));
                            }
                        }
                    },
                    0.3,
                    5
                );
            }),
            (t.prototype.initLayer_UI = function () {
                (this.viewModel.skill_shield.active = this.gameModel == u.GameModel.eatChicken),
                    (this.viewModel.skill_missile.active = this.gameModel == u.GameModel.eatChicken),
                    (this.viewModel.porp_magnet.active = !1),
                    (this.viewModel.porp_double.active = !1),
                    (this.viewModel.view_life.active = this.gameModel == u.GameModel.eatChicken),
                    (this.viewModel.view_gameTimer.active = this.gameModel == u.GameModel.TimeLimit),
                    (this.viewModel.view_score.active = this.gameModel != u.GameModel.eatChicken),
                    (this.viewModel.view_killToast.active = !1),
                    (this.viewModel.view_killList.active = this.gameModel == u.GameModel.eatChicken),
                    (this.viewModel.view_rankingList.active = this.gameModel != u.GameModel.eatChicken),
                    (this.viewModel.back.active = this.gameModel == u.GameModel.TimeLimit),
                    u.default.instance.isStoreHose &&
                        ((this.viewModel.view_rankingList.active = !1), (this.viewModel.view_store_home.active = !0)),
                    (this.viewModel.view_joystick.x = -cc.winSize.width / 2 + 210),
                    (this.viewModel.view_accelerate.x = cc.winSize.width / 2 - 210),
                    this.gameModel == u.GameModel.TimeLimit
                        ? ((this._timer = d.default.GameTimer), this.schedule(this.gameCountDown, 1))
                        : this.gameModel == u.GameModel.eatChicken || (this.gameModel, u.GameModel.endless);
            }),
            (t.prototype.gameCountDown = function () {
                if (0 != this._timer) {
                    this._timer--;
                    var e = Math.floor(this._timer / 60),
                        t = this._timer % 60;
                    if (
                        ((this.viewModel.label_countDown.getComponent(cc.Label).string = e + "分" + t + "秒"),
                        this._timer <= 0)
                    ) {
                        var n = ad.curr_platform === window.ad.Platform.TOU_TIAO;
                        u.default.instance.GameModel === u.GameModel.TimeLimit &&
                            (game.log("T=> 结算排位模式"), n && window.tt.reportAnalytics("Moshi_PaiWei_End", {})),
                            (u.default.instance.gameState = u.GameState.stop),
                            ad.curr_platform == window.ad.Platform.OPPO
                                ? (o.Insance.hideOppoBanner(),
                                  o.Insance.hideVivoBanner(),
                                  ad.adInterface.isNativePatchReady()
                                      ? game.PopupManager.instance.showPopView(
                                            s.default.PopupMap.GameOverView1_1,
                                            null,
                                            !1,
                                            !1
                                        )
                                      : game.PopupManager.instance.showPopView(
                                            s.default.PopupMap.GameOverView1,
                                            null,
                                            !1,
                                            !1
                                        ))
                                : (u.default.instance.tt_recorder_flags && o.Insance.onClick_btn_recorder(),
                                  game.PopupManager.instance.showPopView(
                                      s.default.PopupMap.GameOverView1,
                                      null,
                                      !1,
                                      !1
                                  ));
                    }
                }
            }),
            (t.prototype.onSnakeMoving = function (e) {
                this.isGuideLeft ||
                    ((this.isGuideLeft = !0), (this.guideLeft.active = !1), l.default.setItem("isGuideLeft", "true")),
                    (e = e.normalize()),
                    this._layer_snake.playerControl.onSnakeMoving(e);
            }),
            (t.prototype.onTouchAccelerateStart = function () {
                this.isGuideRight ||
                    ((this.isGuideRight = !0),
                    (this.guideRight.active = !1),
                    l.default.setItem("isGuideRight", "true")),
                    this.viewModel.view_accelerate.getChildByName("image_speet").stopAllActions(),
                    cc.tween(this.viewModel.view_accelerate.getChildByName("image_speet")).to(0.2, {scale: 1}).start(),
                    (this.viewModel.view_accelerate.getChildByName("image_speet").getChildByName("image_speet").active =
                        !1),
                    (this.viewModel.view_accelerate
                        .getChildByName("image_speet")
                        .getChildByName("image_speet2").active = !0),
                    this._layer_snake.playerControl.onSnakeAccelerate(!0);
            }),
            (t.prototype.onTouchAccelerateEnd = function () {
                this.viewModel.view_accelerate.getChildByName("image_speet").stopAllActions(),
                    cc.tween(this.viewModel.view_accelerate.getChildByName("image_speet")).to(0.2, {scale: 1}).start(),
                    (this.viewModel.view_accelerate.getChildByName("image_speet").getChildByName("image_speet").active =
                        !0),
                    (this.viewModel.view_accelerate
                        .getChildByName("image_speet")
                        .getChildByName("image_speet2").active = !1),
                    this._layer_snake.playerControl.onSnakeAccelerate(!1);
            }),
            (t.prototype.__start = function () {
                var e = this;
                this.scheduleOnce(function () {
                    e.initLayer_UI(), e.scheduleOnce(function () {}, 0);
                }, 0),
                    this.param && this.param.isCloseMask
                        ? (this.viewModel.layer_UI.getChildByName("loading").active = !1)
                        : (this.viewModel.layer_UI.getChildByName("loading").active = !0),
                    this.scheduleOnce(function () {
                        if ("限时模式" == u.default.instance.GameModel)
                            e.init(), (e.viewModel.layer_UI.getChildByName("loading").active = !1);
                        else {
                            game.PopupManager.instance.showPopView(s.default.PopupMap.SkinTrialView, t, !1, !1);
                            var o = cc.find("Canvas/_popupViewLayer/SkinTrialView");
                            console.log("node:", o.getComponent("SkinTrialView")),
                                o.getComponent("SkinTrialView").showCallBack(function () {
                                    e.init(),
                                        (e.viewModel.layer_UI.getChildByName("loading").active = !1),
                                        ad.curr_platform == window.ad.Platform.TOU_TIAO &&
                                            (u.default.instance.tt_recorder_flags || e.onClick_btn_recorder());
                                });
                        }
                    }, 1.5);
            }),
            (t.prototype.onClick_btn_recorder = function () {
                u.default.instance.tt_recorder_flags = !u.default.instance.tt_recorder_flags;
                var e = this.viewModel.btn_recorder.getChildByName("recorder_image").getComponent(cc.Sprite);
                u.default.instance.tt_recorder_flags
                    ? ((e.spriteFrame = this.Recordering), ad.adInterface.ttStartRecorder())
                    : ((e.spriteFrame = this.Recorder_stop), ad.adInterface.ttStopRecorder());
            }),
            (t.prototype.init = function () {
                (this._view_killList = this.viewModel.view_killList.getComponent(v.default)),
                    (this._layer_blast = this.viewModel.layer_blast.addComponent(m.default)),
                    u.default.instance.isStoreHose
                        ? (this._layer_food = this.viewModel.layer_food.addComponent(w.default))
                        : (this._layer_food = this.viewModel.layer_food.addComponent(P.default)),
                    u.default.instance.isStoreHose
                        ? (this._layer_snake = this.viewModel.layer_snake.addComponent(b.default))
                        : (this._layer_snake = this.viewModel.layer_snake.addComponent(I.default)),
                    u.default.instance.GameModel == u.GameModel.eatChicken &&
                        (this._poisonMap = this.viewModel.layer_poison.addComponent(g.default)),
                    this.param && this.setKillParam(this.param),
                    this.initRankingListView(),
                    this.refreshPorp_Shield(0);
                var e = game.BundleManager.instance
                    .getBundle(c.default.Game)
                    .get(s.default.GameBundle.sounds.assetsList.BGMusic, cc.AudioClip);
                game.AudioManager.playBGM(e, !0),
                    u.default.instance.isStoreHose && (game.log("开始倒计时,发送通知"), this.startStoreHoseCountDown()),
                    (u.default.instance.gameState = u.GameState.play);
            }),
            (t.prototype.refreshCameraPos = function (e, t) {
                (this._gameCameraPos = e),
                    (this.viewModel.GameCamera.x = e.x),
                    (this.viewModel.GameCamera.y = e.y),
                    (this.viewModel.GameCamera.z = 1024 * t < 1200 ? 1024 * t : 1200);
            }),
            (t.prototype.update = function (e) {
                if (u.default.instance.gameState == u.GameState.play)
                    if ((this.refreshUserDate(), this._batch++, this._batch % 4 == 0)) this._layer_food.updateF();
                    else if (this._batch % 4 == 2) this._layer_snake.updateF();
                    else
                        for (var t = 0, o = this._layer_snake.snakeList.length; t < o; t++)
                            this._layer_snake.snakeList[t].__update(e);
            }),
            (t.prototype.refreshUserDate = function () {
                if ((this.refreshProgressTaskTip(), u.default.instance.GameModel != u.GameModel.eatChicken)) {
                    var e,
                        t = u.default.instance.RankingDataList,
                        o = u.default.instance.SelfPlayerData;
                    u.default.instance.GameModel == u.GameModel.endless
                        ? (e = u.default.instance.HighestScoreInHistory_endless)
                        : u.default.instance.GameModel == u.GameModel.TimeLimit &&
                          (e = u.default.instance.HighestScoreInHistory_TimeLimit);
                    for (var n = this.viewModel.rankContent.children, i = 0, a = 0; a < n.length; a++) {
                        var r = n[a];
                        a >= t.length
                            ? (r.active = !1)
                            : ((r.active = !0),
                              (r.getChildByName("data").getComponent(cc.Label).string =
                                  t[a].snakeName + ":" + t[a].fraction),
                              t[a].snakeName == o.snakeName
                                  ? (r.getChildByName("data").color = new cc.Color(0, 255, 0, 255))
                                  : (r.getChildByName("data").color = new cc.Color(255, 255, 255, 255))),
                            r.active && i++;
                    }
                    if (
                        ((this.viewModel.rankContent.height = (i + 2) * n[0].height),
                        (this.viewModel.view_score.getChildByName("label_old").getComponent(cc.Label).string = e),
                        (this.viewModel.view_score.getChildByName("label_now").getComponent(cc.Label).string =
                            o.fraction.toString()),
                        o.fraction >= N.default.COMEIN_SCORE &&
                            !u.default.instance.isIncome &&
                            this.gameModel == u.GameModel.endless)
                    ) {
                        if (this.isCreate) return;
                        (this.isCreate = !0),
                            game.appFacade.sendNotification(_.default.CREATE_STORE_HOSE),
                            (this.viewModel.layer_UI.getChildByName("store_bg_2").active = !1),
                            (this.viewModel.view_store_home.active = !0),
                            (this.viewModel.label_store_home_countDown.active = !1),
                            (this.viewModel.view_store_home.getChildByName("label_tip").active = !1);
                    }
                    if (
                        (o.fraction >= N.default.TIP_SCORE &&
                            !u.default.instance.isIncome &&
                            !this.ifTipStore &&
                            this.gameModel == u.GameModel.endless &&
                            ((this.ifTipStore = !0),
                            (this.viewModel.layer_UI.getChildByName("store_bg_2").active = !0)),
                        this.gameModel == u.GameModel.endless &&
                            !u.default.instance.isIncome &&
                            this.oldScore != o.fraction)
                    ) {
                        this.oldScore = o.fraction;
                        var s = this.viewModel.layer_UI.getChildByName("store_bg_2");
                        (s.getChildByName("pro_num").getComponent(cc.Label).string =
                            o.fraction + "/" + N.default.COMEIN_SCORE),
                            (s.getChildByName("pro_bg").getComponent(cc.ProgressBar).progress =
                                o.fraction / N.default.COMEIN_SCORE);
                    }
                }
            }),
            (t.prototype.refreshProgressTaskTip = function () {
                for (
                    var e = u.default.instance.SelfPlayerData.fraction,
                        t = f.default.instance.getScore(),
                        o = f.default.instance.taskListScore,
                        n = 0,
                        i = e + t,
                        a = 0;
                    a < o.length;
                    a++
                )
                    i >= (r = o[a]) && (n = a + 1);
                if (n == o.length) this.viewModel.progressTaskTip.active = !1;
                else {
                    var r = o[n] - i,
                        s = f.default.instance.taskListName[n];
                    (this.viewModel.progressTaskTip.active = !0),
                        (this.viewModel.progressTaskTip.getChildByName("label").getComponent(cc.Label).string =
                            "再赢" + r + "长度即可\n获得" + s),
                        (this.viewModel.progressTaskTip
                            .getChildByName("progress")
                            .getComponent(cc.ProgressBar).progress = i / o[n]);
                }
            }),
            (t.prototype.initSnakeName = function (e) {
                if (
                    (this._view_killList.label_surplusSnake_num++,
                    this.viewModel.layer_snakesName.getChildByName("snakeName"))
                )
                    return (this.viewModel.layer_snakesName.getChildByName("snakeName").active = !0);
                var t = game.UIManager.instance.createNodeByPreloading(
                    c.default.Game,
                    s.default.GameBundle.prefabs.assetsList.snakeName
                );
                (t.name = e),
                    (t.x = 1e4),
                    (t.parent = this.viewModel.layer_snakesName),
                    (t.getComponent(cc.Label).string = e);
            }),
            (t.prototype.refreshSnakeName = function (e, t, o) {
                void 0 === o && (o = 1),
                    this.viewModel.layer_snakesName.children.forEach(function (n) {
                        n.name == e && ((n.active = !0), (n.position = cc.v3(t.x, t.y - -120, 0)), (n.scale = o));
                    });
            }),
            (t.prototype.isShowSnakeName = function (e, t) {
                void 0 === t && (t = !1),
                    this._view_killList.label_surplusSnake_num--,
                    this.viewModel.layer_snakesName.children.forEach(function (o) {
                        o.name == e && (o.active = t);
                    });
            }),
            (t.prototype.initRankingListView = function () {
                for (var e = 0; e < 10; e++) {
                    var t = game.UIManager.instance.createNodeByPreloading(
                        c.default.Game,
                        s.default.GameBundle.prefabs.assetsList.rankItem
                    );
                    if (
                        ((t.parent = this.viewModel.rankContent),
                        (t.y = 0 - e * (t.height + 5) - t.height / 2),
                        (t.active = !1),
                        (t.getChildByName("index_label").getComponent(cc.Label).string = (e + 1).toString()),
                        e < 3)
                    ) {
                        (t.getChildByName("index_label").active = !1), (t.getChildByName("index_sprite").active = !0);
                        var o = "game_ranking" + (e + 1),
                            n = game.BundleManager.instance
                                .getBundle(c.default.Game)
                                .get(s.default.GameBundle.textures.assetsList[o], cc.SpriteFrame);
                        t.getChildByName("index_sprite").getComponent(cc.Sprite).spriteFrame = n;
                    }
                }
                var i = this.viewModel.rankContent.children[0].height;
                this.viewModel.rankContent.height = 10 * (i + 5);
            }),
            (t.prototype.TOUCH_START_Missile = function () {
                this._layer_snake.playerControl.showMissileSize(!0);
            }),
            (t.prototype.TOUCH_END_Missile = function () {
                this._layer_snake.playerControl.showMissileSize(!1), this._layer_snake.playerControl.useMissile();
            }),
            (t.prototype.TOUCH_CANCEL_Missile = function () {
                this._layer_snake.playerControl.showMissileSize(!1);
            }),
            (t.prototype.onClick_Shield = function () {
                this._layer_snake.playerControl.useShield();
            }),
            (t.prototype.refreshMagnetTimer = function (e, t) {
                (this.viewModel.porp_magnet.active = e),
                    e && (this.viewModel.porp_magnet.getChildByName("timer_label").getComponent(cc.Label).string = t);
            }),
            (t.prototype.refreshDoubleTimer = function (e, t) {
                (this.viewModel.porp_double.active = e),
                    e && (this.viewModel.porp_double.getChildByName("timer_label").getComponent(cc.Label).string = t);
            }),
            (t.prototype.refreshPorp_Missile = function (e) {
                this.viewModel.view_accelerate
                    .getChildByName("skill_missile")
                    .getChildByName("label_num")
                    .getComponent(cc.Label).string = e.toString();
            }),
            (t.prototype.refreshPorp_MissileProgress = function (e) {
                this.viewModel.view_accelerate
                    .getChildByName("skill_missile")
                    .getChildByName("progress_timer")
                    .getComponent(cc.ProgressBar).progress = e / 100;
            }),
            (t.prototype.refreshPorp_Shield = function (e) {
                var t = this.viewModel.view_accelerate.getChildByName("skill_shield");
                t.getChildByName("label_num").getComponent(cc.Label).string = Math.floor(e / 10).toString();
                var o = e % 10;
                (o = 10 - o),
                    (t.getChildByName("progress_timer").getComponent(cc.ProgressBar).progress = e >= 10 ? 0 : o / 10);
            }),
            (t.prototype.refreshUILife = function (e) {
                e < 0 && (e = 0),
                    (this.viewModel.view_life.getChildByName("label_life").getComponent(cc.Label).string =
                        e.toString());
                for (var t = this.viewModel.view_life.getChildByName("stars"), o = 0; o < t.children.length; o++) {
                    var n = t.children[o];
                    if (e < 1e3 * o) n.getChildByName("progress").getComponent(cc.ProgressBar).progress = 0;
                    else if (e > 1e3 * (o + 1)) n.getChildByName("progress").getComponent(cc.ProgressBar).progress = 1;
                    else if (e <= 1e3 * (o + 1) && e >= 1e3 * o) {
                        var i = e - 1e3 * o;
                        n.getChildByName("progress").getComponent(cc.ProgressBar).progress = i / 1e3;
                    }
                }
            }),
            (t.prototype.sendMissile = function (e, t, o, n, i) {
                var a = h.default.instance.getBombNode();
                (a.parent = this.viewModel.layer_bomb),
                    (a.getComponent(y.default)._snakeName = e),
                    (a.getComponent(y.default)._world_pos = cc.v2(t.x, t.y)),
                    (a.getComponent(y.default)._vector = o),
                    (a.getComponent(y.default)._skin_index = n),
                    (a.getComponent(y.default).angle = i),
                    a.getComponent(y.default).init();
            }),
            (t.prototype.showOppoBanner = function () {}),
            (t.prototype.showVivoBanner = function () {}),
            (t.prototype.hideOppoBanner = function () {}),
            (t.prototype.hideVivoBanner = function () {}),
            (t.prototype.onRemoveToScene = function () {
                e.prototype.onRemoveToScene.call(this),
                    this.hideOppoBanner(),
                    this.hideVivoBanner(),
                    (o.Insance = null),
                    (cc.find("Canvas/Main Camera").active = !0);
            }),
            (t.prototype.checkStoreHoseModel = function () {
                if (
                    ((u.default.instance.isStoreHose = !1),
                    (this.param && 0 !== Object.keys(this.param).length) || (u.default.instance.isIncome = !1),
                    this.param && 0 !== Object.keys(this.param).length && this.param.isStoreHose)
                ) {
                    u.default.instance.isIncome = !0;
                    var e = this.param;
                    (this.storeHoseModel = new N.default(e)),
                        (this.param = this.storeHoseModel.getNewParam()),
                        game.log("初始化storeHoseModel");
                }
            }),
            (t.prototype.setKillParam = function (e) {
                (this._view_killList._label_userKill_num = e.killNum), (this._view_killList.onceKill = e.isFirstKill);
            }),
            (t.prototype.startStoreHoseCountDown = function () {
                game.log("执行startStoreHoseCountDown"),
                    this.unschedule(this.countDown),
                    this.schedule(this.countDown, 1);
            }),
            (t.prototype.stopStoreHoseCountDown = function () {
                this.unschedule(this.countDown);
            }),
            (t.prototype.countDown = function () {
                --this.storeHoseModel.countTime,
                    this.storeHoseModel.countTime <= 0
                        ? (this.stopStoreHoseCountDown(), this.portalBack())
                        : (this.viewModel.label_store_home_countDown.getComponent(cc.Label).string =
                              this.storeHoseModel.formatTime());
            }),
            (t.prototype.portalBack = function () {
                var e = this.param,
                    t = this._layer_snake.playerControl.getSnakesParam();
                (e.score = t.score), (e.aiData = t.aiData);
                var o = this.storeHoseModel.mergeParam(e);
                game.UIManager.instance.replaceModuleView(
                    c.default.Game,
                    s.default.GameBundle.prefabs.assetsList.GameModuleView,
                    o
                );
            }),
            (t.prototype.clickBackGame = function () {
                var e = new Date().getTime();
                if (e - this.preClickTimer >= 1e3)
                    return game.UIManager.instance.showToast("再按一次回到游戏大厅"), void (this.preClickTimer = e);
                game.UIManager.instance.replaceModuleView(
                    c.default.Start,
                    s.default.StartBundle.prefabs.assetsList.StartModuleView
                );
            }),
            (t.Insance = null),
            r([R(B.default)], t.prototype, "testDebug", void 0),
            r([R(cc.SpriteFrame)], t.prototype, "Recordering", void 0),
            r([R(cc.SpriteFrame)], t.prototype, "Recorder_stop", void 0),
            (o = r([O], t))
        );
    })(game.BaseModuleView);
i.default = T;
